package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 褚金龙
 * @Date 2024/9/7 1:43
 */

@Slf4j
@RestController("AdminShopController")
@RequestMapping("/admin/shop")
@CrossOrigin("*")
@Api(tags = "营业状态设置")
public class ShopController {
    public  static final String KEY="SHOP_STATUS";
    @Autowired
    private RedisTemplate redisTemplate;

    @ApiOperation("营业状态设置")
    @PutMapping("/{status}")
     public Result updateStatus(@PathVariable Integer status){
        ValueOperations valueOperations = redisTemplate.opsForValue();

        valueOperations.set(KEY,status);
        return Result.success();
    }

    @GetMapping("/status")
    @ApiOperation("营业状态查询")
    public  Result queryStatus(){
        ValueOperations valueOperations = redisTemplate.opsForValue();
        Integer status = (Integer) valueOperations.get(KEY);
        return Result.success(status);

    }
}
